#include <stdio.h>

void pixelar_c (
	unsigned char *src,
	unsigned char *dst,
	int m,
	int n,
	int src_row_size,
	int dst_row_size
) {
	int fila = 0;
	int columna = 0;
	int promedio = 0;

	for (fila = 0; fila < m; fila+=4 ){
		for (columna = 0; columna < n; columna+=4 ){
			promedio = 0;
			for (int i=0; i<4; i++){
				promedio += (src[(fila*m)+(i*src_row_size)+columna] + src[(fila*m)+(i*src_row_size)+columna+1] + src[(fila*m)+(i*src_row_size)+columna+2] + src[(fila*m)+(i*src_row_size)+columna+3]);
			}			
			promedio = promedio/16;
			for (int i=0; i<4; i++){
				dst[(fila*m)+(i*dst_row_size)+columna] = (unsigned char)promedio;
				dst[(fila*m)+(i*dst_row_size)+columna+1] = (unsigned char)promedio;
				dst[(fila*m)+(i*dst_row_size)+columna+2] = (unsigned char)promedio;
				dst[(fila*m)+(i*dst_row_size)+columna+3] = (unsigned char)promedio;
			}			
		}
	}

}
